package bubbleSort;

import emergent.Rule;

public class LookRight implements Rule<BubbleSortWorld,Number> {

	@Override
	public void doAction(BubbleSortWorld world, Number agent) {
		int temp = agent.getRightHandSideAgent().getNumberValue();
		agent.getRightHandSideAgent().setNumberValue(agent.getNumberValue());
		agent.setNumberValue(temp);
		world.numberOfSwaps++;
	}

	@Override
	public boolean verifyGuard(BubbleSortWorld world, Number agent) {
		Number rightHandSideAgent = agent.getRightHandSideAgent();
		if (rightHandSideAgent == null) return false;
		return (rightHandSideAgent.getNumberValue()<agent.getNumberValue());
	}

}
